<?php

// Undo magic quotes
if (get_magic_quotes_gpc()) {

    function stripslashes_gpc(&$value) {
        $value = stripslashes($value);
    }

    array_walk_recursive($_GET, 'stripslashes_gpc');
    array_walk_recursive($_POST, 'stripslashes_gpc');
    array_walk_recursive($_COOKIE, 'stripslashes_gpc');
    array_walk_recursive($_REQUEST, 'stripslashes_gpc');
}

define('APPLICATION_NAME', 'toi');

function d($param, $die = true) {
    echo '<pre>';
    print_r($param);
    echo '</pre>';
//    Zend_Debug::dump($param);
    if ($die) {
        die('END');
    }
}

define('APPLICATION_PUBLIC', realpath(dirname(__FILE__)));

// Define application environment
defined('APPLICATION_ENV')
        || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
if (APPLICATION_ENV == 'development') {
    // Define path to application directory
    defined('APPLICATION_PATH')
            || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
} else {
    // Define path to application directory
    defined('APPLICATION_PATH')
            || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../_apps/' . APPLICATION_NAME . '/application'));
}

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
            realpath(APPLICATION_PATH . '/../library'),
            realpath(APPLICATION_PATH . '/../../zflibs'),
            realpath(APPLICATION_PATH . '/../../../zflibs'),
//            get_include_path(),
        )));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
                APPLICATION_ENV,
                APPLICATION_PATH . '/configs/application.ini'
);

$application->bootstrap()
        ->run();